package com.example.question.array;

public class Code06_26 {
    public static void main(String[] args) {
        Code06_26 code = new Code06_26();
        int i = code.removeDuplicates(new int[]{1, 1, 2});
        System.out.println(i);
    }

    public int removeDuplicates(int[] nums) {
        int index = 1;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[index++] = nums[i];
            }
        }
        return index;
    }
}
